package com.example.statelayouthelper

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.example.statelayouthelper.databinding.ActivityDemo2Binding

/**
 * @Description: 配置参数自定义 Demo
 * @Author: TomHawk
 * @CreateDate: 2022/8/18 15:27
 */
class Demo2Activity : AppCompatActivity() {
    private lateinit var binding: ActivityDemo2Binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityDemo2Binding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.vpPagers.adapter = object : FragmentStateAdapter(this) {
            override fun getItemCount() = 2
            override fun createFragment(position: Int): Fragment {
                return if (position == 0) Demo21Fragment() else Demo22Fragment()
            }
        }
    }
}